using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using Microsoft.HomeServer.Extensibility;
using Microsoft.HomeServer.SDK.Interop.v1;
using System.Configuration;

namespace Microsoft.HomeServer.HomeServerConsoleTab.StayAlive
{
    public partial class MainTabUserControl : UserControl, INotificationCallback
    {
        IConsoleServices consoleServices;
        WHSInfoClass whsInfoClass;

        public MainTabUserControl()
        {
            InitializeComponent();
        }

        public MainTabUserControl(int width, int height, IConsoleServices consoleServices)
            : this()
        {
            this.Width = width;
            this.Height = height;
            this.consoleServices = consoleServices;
            this.whsInfoClass = new WHSInfoClass();
            this.whsInfoClass.RegisterForNotifications(this);
            try
            {
                this.AppFolder = whsInfoClass.GetApplicationFolder(new Guid("47d62350-ceed-11dd-ad8b-0800200c9a66"));
            }
            catch (Exception)
            {
                this.AppFolder = whsInfoClass.CreateApplicationFolder(new Guid("47d62350-ceed-11dd-ad8b-0800200c9a66"), "Stay Alive");
            }
        }

        #region INotificationCallback Members

        public IApplicationFolder AppFolder { get; set; }

        public void BackupStateChanged(WHSBackupState State)
        {
        }

        public void Disconnected()
        {
        }

        public void NotificationChanged(string UniqueID, WHS_Notification_Type Type, WHS_Notification_Severity Severity, int IsSuppressed, string textHeader, string textDescription, string helpFilename, string helpSection, string helpLinkText)
        {
            this.fancyListView1.Items.Add(Type + " " + Severity + ": " + textHeader + " " + textDescription);
        }

        public void PhysicalDiskChanged(IDiskInfo pDiskInfo)
        {
        }

        public void ReConnected()
        {
        }

        public void UserInfoChanged()
        {
            this.fancyListView1.Items.Add("User info changed!");
        }

        #endregion

        private void consoleToolBarButton1_Click(object sender, EventArgs e)
        {
            this.fancyListView1.Items.Clear();
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            Application.SetSuspendState(PowerState.Suspend, true, false);

        }

    }
}
